package com.xbongbong.pro.dataset.exception;

/**
 * @author gzt
 * @version 1.0
 * @Description -
 * @datetime - 2022/5/20-10:28
 * @since v1.0
 */
public class DataBaseAccessException extends Exception{
    private static final long serialVersionUID = 1L;
    private String m_strErrorCode;
    private int m_iDBAType;
    private String m_strErrorMessage;
    private Exception m_e;

    public DataBaseAccessException() {
    }

    public DataBaseAccessException(Throwable cause) {
        super(cause);
    }

    public DataBaseAccessException(String message, Throwable cause) {
        super(message, cause);
    }

    public DataBaseAccessException(String message) {
        this.m_strErrorMessage = message;
    }

    public DataBaseAccessException(String code, String message) {
        this.m_strErrorCode = code;
        this.m_strErrorMessage = message;
    }

    public DataBaseAccessException(String code, Exception e) {
        this.m_strErrorCode = code;
        this.m_e = e;
    }

    public String getCode() {
        return this.m_strErrorCode;
    }

    @Override
    public String getMessage() {
        if (this.m_strErrorMessage != null) {
            return this.m_strErrorMessage;
        } else {
            return this.m_e != null ? this.m_e.getMessage() : null;
        }
    }

    public int getType() {
        /*if (this.m_strErrorCode.startsWith("1")) {
            this.m_iDBAType = 1;
        } else if (this.m_strErrorCode.startsWith("2")) {
            this.m_iDBAType = 2;
        } else if (this.m_strErrorCode.startsWith("3")) {
            this.m_iDBAType = 3;
        } else if (this.m_strErrorCode.startsWith("4")) {
            this.m_iDBAType = 4;
        } else {
            if (!this.m_strErrorCode.startsWith("5")) {
                return -1;
            }

            this.m_iDBAType = 5;
        }
*/
        return this.m_iDBAType;
    }
}
